package cn.zyjw.mapper;

import cn.zyjw.entity.SysPrivilege;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface SysPrivilegeMapper extends BaseMapper<SysPrivilege> {

    @Select("SELECT `name` FROM sys_privilege")
    Set<String> queryAllPermissions();

    @Select("SELECT `name` FROM sys_privilege LEFT JOIN sys_role_privilege ON sys_role_privilege.privilege_id = sys_privilege.id LEFT JOIN sys_user_role  ON sys_role_privilege.role_id = sys_user_role.role_id WHERE sys_user_role.user_id = #{sysUserId}")
    Set<String> queryPermissionByUserId(Long sysUserId);
}
